<?php
include("connection/connection.php");
$typeScheme=$_POST['typeScheme'];
$frm=$_POST['frmId'];
if(isset($_POST['submit']))
{
$loc_id=$_POST['loc_id'];
$code=$_POST['code'];
$Status=$_POST['Status'];
$Discharge=$_POST['Discharge'];
$Discharge=$_POST['Discharge'];
$Head=$_POST['Head'];
$Power=$_POST['Power'];
if($code==1)
{
$qr="insert into tbl_dtls_q1_asset (loc_id,asset_id,asset_location,asset_latitude,asset_longitude,asset_status,asset_discharge,asset_head,asset_power,status) values('$loc_id','Sub','$_REQUEST[Location]','$_REQUEST[Latitude]','$_REQUEST[Longitude]','$Status','$Discharge','$Head','$Power','1')";
}
if($code==2)
{
$qr="insert into tbl_dtls_q1_asset (loc_id,asset_id,asset_location,asset_latitude,asset_longitude,asset_status,asset_discharge,asset_head,asset_power,status) values('$loc_id','mono','$_REQUEST[Location]','$_REQUEST[Latitude]','$_REQUEST[Longitude]','$Status','$Discharge','$Head','$Power','1')";
}
if($code==3)
{
$qr="insert into tbl_dtls_q1_asset (loc_id,asset_id,asset_location,asset_latitude,asset_longitude,asset_status,asset_discharge,asset_head,asset_power,status) values('$loc_id','centi','$_REQUEST[Location]','$_REQUEST[Latitude]','$_REQUEST[Longitude]','$Status','$Discharge','$Head','$Power','1')";
}
if($code==4)
{
$qr="insert into tbl_dtls_q1_asset (loc_id,asset_id,asset_location,asset_latitude,asset_longitude,asset_status,asset_discharge,asset_head,asset_power,status) values('$loc_id','Sp','$_REQUEST[Location]','$_REQUEST[Latitude]','$_REQUEST[Longitude]','$Status','$Discharge','$Head','$Power','1')";
}

$res=mysql_query($qr);

if($res)
{
	if($code==1)
	{
		$update_query="update tbl_dtls_q1_main set sub_total=(sub_total+1) where id='$loc_id'";
	}
	if($code==2)
	{
		$update_query="update tbl_dtls_q1_main set mono_total=(mono_total+1) where id='$loc_id'";
	}
	if($code==3)
	{
		$update_query="update tbl_dtls_q1_main set centi_total=(centi_total+1) where id='$loc_id'";
	}
	if($code==4)
	{
		$update_query="update tbl_dtls_q1_main set sp_total=(sp_total+1) where id='$loc_id'";
	}

	$res1=mysql_query($update_query);
	
	////////////////////////code for maintaining user history///////////////////
	if($typeScheme=="P&T" || $typeScheme=="TSS(P&T)")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','10','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Piped")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','36','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Sanitary Diggs")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','62','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	
	
	mysql_query($qryHistory);
	///////////////////////////////
	
	
	if($res1)
	{
		header("location:q1.php");
	}
}

}		
?>